from django.test import TestCase


# Create your tests here.

# getattr 方法解析

class myView():
    a = 'a'
    b = 'b'

    def get_a(self):
        return self.a

    def get_b(self):
        return self.b


mv = myView()

mv_method_geta1 = mv.get_a
print(type(mv_method_geta1))
print(mv_method_geta1())

mv_method_geta2 = getattr(mv, 'get_a')
print(type(mv_method_geta2))
print(mv_method_geta2())

print(mv_method_geta1 == mv_method_geta2)
# print(getattr(mv, 'a'))
